package april.test_4_1;


import javax.swing.plaf.basic.BasicInternalFrameTitlePane;

import java.util.ArrayList;
import java.util.List;

import static java.lang.Integer.MAX_VALUE;

public class TestMain1 {
    public int[] solution(int[] costs, int coins) {
        List<Integer> list = new ArrayList<>();
        while (coins >= 0) {
            int min = coins;
            int tmp = 0;
            for (int i = 0; i < costs.length; i++) {
                if(costs[i] != -1 && costs[i] < min) {
                    min = costs[i];
                    tmp = i;
                }
            }
            coins -= min;
            list.add(costs[tmp]);
            costs[tmp] = -1;
        }
        int[] results = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            results[i] = list.get(i);
        }
        return results;
    }
}
